/** @file tree.h
 *
 *  The general tree class.
 *
 *  @author Dongryeol Lee (drselee@gmail.com)
 */

#ifndef CORE_TREE_TREE_H
#define CORE_TREE_TREE_H

namespace core {
namespace tree {

class Tree {
  private:

    /** @brief The beginning positions in the child_indices
     *         array. Sort of like a cumulative distribution on the
     *         number of child nodes. This has (num_nodes_ + 1)
     *         numbers.
     */
    int *child_begin_indices_;

    /** @brief Using the child_begin_indices_, quickly enumerate the
     *         child node positions in the global node list.
     */
    int *child_indices_;

    /** @brief The number of nodes in the tree.
     */
    int num_nodes_;

  private:

    inline int num_child_nodes_(int node_id) const {
      return child_begin_indices_[ node_id + 1 ] -
             child_begin_indices_[ node_id ];
    }

  public:

    /** @brief The constructor.
     */
    Tree();

    /** @brief Virtual destructor.
     */
    virtual ~Tree();

    template<typename DatasetType>
    void Construct(const DatasetType &dataset_in);
};
}
}

#endif
